package com.cafuc.discipline.controller;

import com.cafuc.discipline.anno.EncryptFilter;
import com.cafuc.discipline.dao.AffairDao;
import com.cafuc.discipline.entity.Affair;
import com.cafuc.discipline.respone.Result;
import com.cafuc.discipline.service.AffairService;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author Mete
 * @createTime 2022/11/27 16:52
 * @description
 */
@RestController
@Api(tags = "检举管理相关接口")
public class AffairController {
    @Resource
    AffairService affairService;

    @GetMapping("/cafuc/affair/getAll")
    @ApiOperation("查询所有检举-(具体字段说明请查看下方Affair内字段说明)")
//    @ApiImplicitParams({@ApiImplicitParam(paramType = "query",name = "approval_status",value ="状态(0：待处理，1：处理中，2：已完成，3：all)",dataType ="String"),}
//    )
    @ApiResponses({
            @ApiResponse(code=200,message = "操作成功",response = Affair.class)
    })
    @EncryptFilter(decryptRequest = false)
    public Result get(@ApiIgnore @RequestParam HashMap<String, Object> params){
        return affairService.getAllReport(params);
    }


    @GetMapping("/cafuc/affair/gerType")
    @ApiOperation("查询举报类型数据")
    @EncryptFilter(decryptRequest = false)
    public Result getType(){
        return affairService.selectReportType();
    }

    @PostMapping("/cafuc/affair/insert")
    @ApiOperation("检举新增的接口")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "body",name="params",value ="举报信息加密后密文",dataType ="String"),}
    )
    @EncryptFilter
    public Result insertUser(@RequestBody HashMap<String, Object> params){
        return affairService.insertNewAffair(params);
    }
}
